﻿using System.Configuration;

namespace XiaoSe
{
    /// <summary>
    /// 操作config
    /// </summary>
    public class ConfigProcess
    {
        /// <summary>
        /// 获取指定Name的ConnectionStrings的值
        /// </summary>
        /// <param name="name">Name</param>
        /// <returns>返回字符串</returns>
        public static string GetConnectionStrings(string name)
        {
            try
            {
                return ConfigurationManager.ConnectionStrings[name].ToString();
            }
            catch
            {
                return "";
            }
        }

        /// <summary>
        /// 获取指定Key的AppSettings的值
        /// </summary>
        /// <returns>返回字符串</returns>
        public static string GetAppSettings(string key)
        {
            try
            {
                return ConfigurationManager.AppSettings[key];
            }
            catch
            {
                return "";
            }
        }
    }
}
